// KetonalTrayIcon.cpp: implementation of the KetonalTrayIcon class.
//
//////////////////////////////////////////////////////////////////////

#include "Ketonal.h"
#include "KetonalTrayIcon.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

KetonalTrayIcon::KetonalTrayIcon(Ketonal *_p)
{
	parent = _p;
	Image *icon = ImageCache::getFromMemory (tray_png, tray_pngSize);
	setIconImage (*icon);
	setIconTooltip (T("Juce Demo App!"));
}

KetonalTrayIcon::~KetonalTrayIcon()
{
}

void KetonalTrayIcon::mouseDown (const MouseEvent& e)
{
	if (e.mods.isPopupMenu())
	{
		PopupMenu m;
        m.addItem (1, "Options", true, false);

		m.addSeparator();

		m.addItem (2, "About", true, false);
		m.addItem (3, "Exit", true, false);

        const int result = m.show();

		if (result == 1)
		{
			KetonalSettingsWindow *ketonalSettings = new KetonalSettingsWindow(parent);
			ketonalSettings->setVisible (true);
        }
		else if (result == 2)
		{
		}
		else if (result == 3)
		{
			JUCEApplication::quit();
		}
	}
}

void KetonalTrayIcon::mouseDoubleClick (const MouseEvent &e)
{
	parent->trayDoubleClick();
}

static const unsigned char resource_Ketonal_tray_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16,0,0,0,16,8,6,0,0,0,31,243,255,97,0,0,0,1,115,82,71,66,0,174,206,28,233,0,0,0,6,98,75,71,
68,0,255,0,255,0,255,160,189,167,147,0,0,0,9,112,72,89,115,0,0,11,19,0,0,11,19,1,0,154,156,24,0,0,0,7,116,73,77,69,7,216,5,23,10,49,54,51,231,195,73,0,0,2,106,73,68,65,84,56,203,165,147,93,72,211,81,24,
198,127,231,255,223,254,107,110,107,42,126,66,138,149,100,182,139,210,138,168,212,155,160,144,32,34,10,130,18,34,18,36,34,161,171,72,162,66,188,11,33,136,176,155,46,171,155,48,163,48,186,137,52,9,133,
146,204,143,162,76,135,57,117,78,217,135,155,251,252,159,46,230,54,39,121,213,129,3,47,15,231,121,222,135,247,61,15,252,231,17,27,129,150,47,13,101,192,121,160,6,176,0,243,192,0,208,221,85,219,23,216,
84,224,114,223,81,161,89,213,54,155,209,120,59,24,143,107,186,148,27,223,122,129,59,82,151,15,31,31,232,215,83,160,146,42,52,139,218,94,150,99,109,183,25,180,52,185,181,178,147,235,149,247,217,151,91,
143,34,212,92,224,129,80,196,243,230,193,122,99,138,103,0,184,242,169,206,97,215,180,155,21,214,173,124,116,187,0,168,178,213,178,219,182,31,128,106,219,65,188,177,69,6,150,222,240,126,241,197,185,160,
244,187,129,107,105,7,66,225,82,185,197,166,122,163,17,82,198,27,139,155,178,252,231,26,11,57,81,124,129,138,156,106,16,92,109,30,172,59,156,18,16,72,106,236,154,70,84,79,0,176,195,226,160,202,86,155,
37,48,21,28,231,238,248,69,198,252,131,0,66,40,162,53,45,160,199,165,6,96,80,146,35,105,44,73,118,215,165,158,113,160,21,224,141,121,50,211,23,28,3,84,5,144,177,80,98,202,23,141,98,55,106,152,20,51,149,
214,189,244,123,122,184,55,209,68,66,198,1,200,51,22,113,40,255,120,70,64,17,5,123,206,150,90,20,64,46,79,6,223,205,132,86,176,24,140,104,106,156,27,95,79,242,116,166,19,119,228,15,115,225,233,52,169,
161,224,116,186,150,186,12,127,239,153,79,40,0,189,173,99,189,243,238,149,241,201,128,143,157,86,59,146,140,245,153,208,207,228,39,136,121,232,118,117,165,241,72,32,62,162,199,100,76,5,144,9,25,86,12,
138,211,228,48,157,82,84,161,153,84,149,213,68,210,186,42,12,72,116,30,253,190,149,229,102,118,200,219,241,235,237,226,144,154,2,230,134,125,78,69,21,179,230,93,91,234,35,66,55,167,241,240,52,195,222,
15,196,244,72,154,236,249,177,242,242,85,243,72,7,176,170,174,219,84,194,245,217,55,177,48,18,24,202,219,158,83,104,206,215,202,133,34,12,235,87,25,15,235,126,103,255,242,147,215,45,223,218,144,44,252,
51,76,107,171,45,178,151,155,29,213,103,74,143,216,74,76,219,164,68,250,103,87,157,163,207,92,125,161,165,232,40,224,219,52,141,27,130,102,92,187,0,81,32,14,100,165,236,47,186,242,233,153,211,60,149,117,
0,0,0,0,73,69,78,68,174,66,96,130,0,0};

const char* KetonalTrayIcon::tray_png = (const char*) resource_Ketonal_tray_png;
const int KetonalTrayIcon::tray_pngSize = 746;